package com.yz.test.parking.http;

import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;

public class RequestDataManager {

	public static String getSendUrl(String url, Map<String, String> parmMap) {
		if (url == null) {
			return null;
		}
		StringBuilder str = new StringBuilder(url);
		if (parmMap != null) {
			int i = parmMap.size();
			AtomicInteger atomicInteger = new AtomicInteger(0);
			if (url.indexOf("?") <= -1) {
				str.append("?");
			} else {
				str.append("&");
			}
			for (Map.Entry<String, String> parm : parmMap.entrySet()) {
				str.append(parm.getKey());
				str.append("=");
				str.append(parm.getValue());
				if (i - atomicInteger.incrementAndGet() >= 1) {
					str.append("&");
				}
			}
		}

		return str.toString();
	}

}
